package testcase.validationtest;

import junit.framework.TestCase;
import validation.*;
import card.Card;
import card.Cardset;

public class SoloChainTest extends TestCase{
	private Type soloChain;
	private Cardset cardset;
	@Override
	public void setUp(){
		soloChain = SoloChain.getInstance();
	}
	@Override
	public void tearDown(){
		soloChain.clear();
		soloChain=null;
	}
	// testcases
	public void testIdentifyMinCards(){
		cardset = new Cardset(5);
		cardset.clear();
		cardset.add(new Card('s','3'));
		cardset.add(new Card('c','4'));
		cardset.add(new Card('h','5'));
		cardset.add(new Card('d','6'));
		cardset.add(new Card('s','7'));
		Type result = soloChain.identify(cardset);
		assertEquals(result, soloChain);
	}
	
	public void testIdentifyMaxCards(){
		cardset = new Cardset(12);
		cardset.clear();
		cardset.add(new Card('s','3'));
		cardset.add(new Card('c','4'));
		cardset.add(new Card('h','5'));
		cardset.add(new Card('d','6'));
		cardset.add(new Card('s','7'));
		cardset.add(new Card('c','8'));
		cardset.add(new Card('h','9'));
		cardset.add(new Card('d','X'));
		cardset.add(new Card('s','J'));
		cardset.add(new Card('c','Q'));
		cardset.add(new Card('h','K'));
		cardset.add(new Card('d','A'));
		Type result = soloChain.identify(cardset);
		assertEquals(result, soloChain);
	}
	
	public void testIdentifyCardChainWith2(){
		cardset = new Cardset(7);
		cardset.clear();
		cardset.add(new Card('s','9'));
		cardset.add(new Card('c','X'));
		cardset.add(new Card('h','J'));
		cardset.add(new Card('d','Q'));
		cardset.add(new Card('s','K'));
		cardset.add(new Card('c','A'));
		cardset.add(new Card('h','2'));
		Type result = soloChain.identify(cardset);
		assertEquals(result, null);
	}
	
	public void testIdentifyInsufficientCards(){
		cardset = new Cardset(4);
		cardset.clear();
		cardset.add(new Card('s','6'));
		cardset.add(new Card('c','7'));
		cardset.add(new Card('h','8'));
		cardset.add(new Card('d','9'));
		Type result = soloChain.identify(cardset);
		assertEquals(result, null);
	}
	
	public void testIdentifyCardChainAcrossBoundary(){
		cardset = new Cardset(6);
		cardset.clear();
		cardset.add(new Card('g','B'));
		cardset.add(new Card('g','R'));
		cardset.add(new Card('s','3'));
		cardset.add(new Card('c','4'));
		cardset.add(new Card('h','5'));
		cardset.add(new Card('d','6'));
		Type result = soloChain.identify(cardset);
		assertEquals(result, null);
	}
	
	public void testPriorty_1(){
		cardset = new Cardset(5);
		cardset.clear();
		cardset.add(new Card('s','3'));
		cardset.add(new Card('c','4'));
		cardset.add(new Card('h','5'));
		cardset.add(new Card('d','6'));
		cardset.add(new Card('s','7'));
		Cardset temp = new Cardset(5);
		temp.add(new Card('s','4'));
		temp.add(new Card('d','5'));
		temp.add(new Card('h','6'));
		temp.add(new Card('d','7'));
		temp.add(new Card('s','8'));
		soloChain.lessPriorityThan(cardset);
		boolean result = soloChain.lessPriorityThan(temp);
		assertEquals(result, true);
	}
	
	public void testPriorty_2(){
		cardset = new Cardset(7);
		cardset.clear();
		cardset.add(new Card('s','3'));
		cardset.add(new Card('c','4'));
		cardset.add(new Card('h','5'));
		cardset.add(new Card('d','6'));
		cardset.add(new Card('s','7'));
		cardset.add(new Card('h','8'));
		cardset.add(new Card('d','9'));		
		Cardset temp = new Cardset(7);
		temp.add(new Card('s','8'));
		temp.add(new Card('s','9'));
		temp.add(new Card('d','X'));
		temp.add(new Card('h','J'));
		temp.add(new Card('d','Q'));
		temp.add(new Card('s','K'));
		temp.add(new Card('d','A'));
		soloChain.lessPriorityThan(cardset);
		boolean result = soloChain.lessPriorityThan(temp);
		assertEquals(result, true);
	}
	
	public void testPriorty_3(){
		cardset = new Cardset(5);
		cardset.clear();
		cardset.add(new Card('h','5'));
		cardset.add(new Card('d','6'));
		cardset.add(new Card('s','7'));
		cardset.add(new Card('h','8'));
		cardset.add(new Card('d','9'));		
		Cardset temp = new Cardset(5);
		temp.add(new Card('s','5'));
		temp.add(new Card('s','6'));
		temp.add(new Card('d','7'));
		temp.add(new Card('c','8'));
		temp.add(new Card('s','9'));
		soloChain.lessPriorityThan(cardset);
		boolean result = soloChain.lessPriorityThan(temp);
		assertEquals(result, false);
	}	
	
}
